<!-- 导航URL -->
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-md-12">
        <ol class="breadcrumb">
            <li><a>主页</a></li>
            <li><a>收单机构管理</a></li>
            <li class="active"><strong>账单地设置</strong></li>
        </ol>
    </div>
</div>


<!-- 主要内容 -->
<div class="wrapper wrapper-content animated fadeIn" ng-app
     ng-controller="accountAddressCtrl">
    <form class="form-horizontal" id="form1">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <div class="col-sm-10" style="text-align:center">
                            <button class="btn btn-primary5 btn-mr20" type="button" ng-click='accountAreaShow(1)'>新增</button>
                            <button class="btn btn-new btn-mr20" type="button" ng-show="hasPermit('accountAddress.import')" ng-click='importAMShow()'>导入</button>
                            <button class="btn btn-primary7 btn-mr20" type="button" ng-show="hasPermit('accountAddress.export')" ng-click="accountAddressExport()">导出</button>
                            <a href="accountAddress/downloadTemplate">导入模板下载</a>
                        </div>
                        <br />
                        <br />
                        <div class="form-group">
                            <label class="control-label col-sm-2"></label>
                            <div class="col-sm-12" >
                                <div class="gridStyle" ui-grid="accountAreaGrid" ui-grid-pagination ui-grid-auto-resize ui-grid-resize-columns ui-grid-pinning class="grid"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2"></label>
                            <div class="col-sm-12 col-md-offset-4 col-lg-offset-4col-xl-offset-4">
                                <button class="btn btn-primary8 btn-mr20" type="button" ui-sref="org.jumpRoute">返回</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>


    <form class="form-horizontal" id="form3" name="horizontalAccountAreaSetting">
        <div id="accountAreaSetting" class="modal fade" tabindex="-1" data-backdrop="static" role="dialog">
            <div class="modal-dialog" style="width: 900px">
                <div class="modal-content">
                    <div class="modal-body">
                        <div class="form-group">
                            <h3 style="text-align:center">账单地额度设置({{address}})</h3>
                        </div>
                        <div class="form-group">
                            <h4>历史生效记录</h4>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2"></label>
                            <div class="col-sm-12" >
                                <div class="gridStyle" ui-grid="accountAddressTaskGrid" ui-grid-pagination ui-grid-auto-resize ui-grid-resize-columns ui-grid-pinning class="grid"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <h4>账单地额度设置</h4>
                        </div>
                        <div ng-repeat="item in addressGroup">
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><i class="red_req">*</i>账单地额度{{$index + 1}}(元)：</label>
                                <div class="col-sm-2">
                                    <input class="form-control" ng-disabled="item.status == 1" ng-model="item.totalAmount" type="text">
                                </div>
                                <label class="col-sm-2 control-label"><i class="red_req">*</i>生效时间：</label>
                                <div class="col-sm-2">
                                    <input class="form-control ng-pristine ng-untouched ng-valid ng-not-empty" datepicker ng-disabled="item.status == 1" readonly type="datetime" ng-model="item.effectiveTime" onchange="" style="width:auto;display:inline-block;" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:00:00',minDate:'%y-%M-%d #{%H+1}:00:00',onpicked:function(){}})">
                                </div>
                                <label class="col-sm-1 control-label"></label>
                                <div class="col-sm-2">
                                    <input hidden ng-model="item.index" value="$index">
                                    <a  ng-if="$index == 0" ng-click="addAddressGroup($event)">增加</a>&nbsp;<a ng-click="deleteAddressGroup($index)" style="color: red;">删除</a><br />
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-6">
                                <button class="btn btn-primary btn-mr20" type="button" ng-click='addAccountAddressQuota()'
                                >保存
                                </button>
                                <button class="btn btn-primary8" type="button" ng-click='accountAreaSettingCancel()'
                                >取消
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>


    <form class="form-horizontal" name="horizontalAccountAreaAdd">
        <div id="accountAreaAdd" class="modal fade" tabindex="-1" data-backdrop="static" role="dialog">
            <div class="modal-dialog" style="width: 900px">
                <div class="modal-content">
                    <div class="modal-body">
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><i class="red_req">*</i>账单地：</label>
                            <div class="col-sm-3">
                                <select class="form-control" ng-model='accountAreaAddInfo.province' ng-change="provinceChannge()" ng-options="x.text as x.text for x in allProvinceSelect"  >
                                </select>
                            </div>
                            <div class="col-sm-3">
                                <select class="form-control" ng-model='accountAreaAddInfo.city' ng-options="x.text as x.text for x in allCitySelect"  >
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><i class="red_req">*</i>账单地额度(元)：</label>
                            <div class="col-sm-4 form-inline">
                                <input type="text" class="form-control" name="totalAmount" ng-change="toLimit(accountAreaAddInfo,'totalAmount','{{accountAreaAddInfo.totalAmount}}')" ng-model="accountAreaAddInfo.totalAmount" required>元
                                <div class="req_mesg" ng-show="horizontalAccountAreaAdd.totalAmount.$dirty && horizontalAccountAreaAdd.totalAmount.$invalid">
                                    <span ng-show="horizontalAccountAreaAdd.totalAmount.$error.required">账单地额度不能为空</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><i class="red_req">*</i>预留额度(万)：</label>
                            <div class="col-sm-4 form-inline">
                                <input type="text" class="form-control" name="reservedAmount" ng-change="toLimit(accountAreaAddInfo,'reservedAmount','{{accountAreaAddInfo.reservedAmount}}')" ng-model="accountAreaAddInfo.reservedAmount" required>万
                                <div class="req_mesg" ng-show="horizontalAccountAreaAdd.reservedAmount.$dirty && horizontalAccountAreaAdd.reservedAmount.$invalid">
                                    <span ng-show="horizontalAccountAreaAdd.reservedAmount.$error.required">预留额度不能为空</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><i class="red_req">*</i>预留额度释放时间点：</label>
                            <div class="col-sm-4">
                                <input id="d5233" style="width: 150px;" datepicker class="form-control" type="datetime" ng-model="accountAreaAddInfo.releaseTime" required name="releaseTime"  style="width:auto;display:inline-block;"
                                       onFocus="WdatePicker({skin:'whyGreen',dateFmt:'HH:mm:ss'})"/>
                                <div class="req_mesg" ng-show="horizontalAccountAreaAdd.releaseTime.$dirty && horizontalAccountAreaAdd.releaseTime.$invalid">
                                    <span ng-show="horizontalAccountAreaAdd.releaseTime.$error.required">预留额度释放时间点不能为空</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><i class="red_req">*</i>交易时间区间：</label>
                            <div class="col-sm-6 form-inline">
                                <input id="d5231" style="width: 150px;" datepicker class="form-control" type="datetime" ng-model="accountAreaAddInfo.startTime" required name="startTime" style="width:auto;display:inline-block;"
                                       onFocus="WdatePicker({skin:'whyGreen',dateFmt:'HH:mm:ss'})"/>-
                                <input id="d5232" style="width: 150px;" datepicker class="form-control" type="datetime" ng-model="accountAreaAddInfo.endTime" required name="endTime" style="width:auto;display:inline-block;"
                                       onFocus="WdatePicker({skin:'whyGreen',dateFmt:'HH:mm:ss'})"/>
                                <div class="req_mesg" ng-show="horizontalAccountAreaAdd.startTime.$dirty && horizontalAccountAreaAdd.startTime.$invalid">
                                    <span ng-show="horizontalAccountAreaAdd.startTime.$error.required">交易时间区间起始值不能为空</span>
                                </div>
                                <div class="req_mesg" ng-show="horizontalAccountAreaAdd.endTime.$dirty && horizontalAccountAreaAdd.endTime.$invalid">
                                    <span ng-show="horizontalAccountAreaAdd.endTime.$error.required">交易时间区间结束值不能为空</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><i class="red_req">*</i>交易金额区间：</label>
                            <div class="col-sm-6 form-inline">
                                <input type="text" style="width: 150px;" class="form-control" name="minAmount" maxlength="8" ng-change="toLimit(accountAreaAddInfo,'minAmount','{{accountAreaAddInfo.minAmount}}')" ng-model="accountAreaAddInfo.minAmount" required>-
                                <input type="text" style="width: 150px;" class="form-control" name="maxAmount" maxlength="8" ng-change="toLimit(accountAreaAddInfo,'maxAmount','{{accountAreaAddInfo.maxAmount}}')" ng-model="accountAreaAddInfo.maxAmount" required>
                                <div class="req_mesg" ng-show="horizontalAccountAreaAdd.minAmount.$dirty && horizontalAccountAreaAdd.minAmount.$invalid">
                                    <span ng-show="horizontalAccountAreaAdd.minAmount.$error.required">交易金额区间起始值不能为空</span>
                                </div>
                                <div class="req_mesg" ng-show="horizontalAccountAreaAdd.maxAmount.$dirty && horizontalAccountAreaAdd.maxAmount.$invalid">
                                    <span ng-show="horizontalAccountAreaAdd.maxAmount.$error.required">交易金额区间结束值不能为空</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><i class="red_req">*</i>不参与集群轮循：</label>
                            <div class="col-sm-2">
                                <select class="form-control" ng-model='accountAreaAddInfo.joinGroupPolling' ng-options="x.value as x.text for x in joinGroupPollingStatus"></select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><i class="red_req">*</i>启用状态：</label>
                            <div class="col-sm-2">
                                <select class="form-control" ng-model='accountAreaAddInfo.openStatus' ng-options="x.value as x.text for x in accountAreaStatus"></select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"></label>
                            <div class="col-sm-6">
                                <button class="btn btn-primary btn-mr20" type="button" ng-click='addAccountAreaInfo()'
                                        id="btnSubmit1" ng-disabled="horizontalAccountAreaAdd.$invalid">确定
                                </button>
                                <button class="btn btn-primary8" type="button" ng-click='accountAreaCancel()'
                                >取消
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>


    <!-- add import -->
    <form class="form-horizontal" name="horizontalAdd" novalidate>
        <div id="importAM" class="modal fade" tabindex="-1" role="dialog">
            <div class="modal-dialog" style="width: 900px">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" ng-click='importAMCancel()'>
                            &times;
                        </button>
                        <h3 class="modal-title">账单地导入</h3>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">导入文件：</label>
                            <div class="col-sm-3 checkbox ">
                                <input type="file" nv-file-select="" ng-model="fileSelect" uploader="uploader1" multiple/>
                                <table class="table">
                                    <tbody>
                                    <tr ng-repeat="item in uploader1.queue">
                                        <td>
                                            <strong>{{ item.file.name }}</strong>
                                        </td>
                                        <td nowrap>
                                            <button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
                                                <span class="glyphicon glyphicon-trash"></span>删除
                                            </button>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-6">
                                <button class="btn btn-primary btn-mr20" type="button" ng-click='importAddressMapping()'
                                        ng-disabled="uploader1.queue.length==0||submitting">提交
                                </button>
                                <button class="btn btn-primary8" type="button" ng-click='importAMCancel()'
                                >取消
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>

</div>
